﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminCP/Layouts/Admin.Master" AutoEventWireup="true"
    CodeBehind="ProductEdit.aspx.cs" Inherits="Thuoc24h.AdminCP.Pages.ProductEdit" %>

<%@ Import Namespace="Thuoc24h.Common" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphContent" runat="server">
    <script>
        $(function () {

            $('#<%= txtName.ClientID %>').change(function () {
                var alias = ConvertToUnSign(this.value);
                $('#<%= txtUnsignName.ClientID %>').val(alias);
            });


            //            $('#<= txtDiscountPercent.ClientID %>').blur(function () {
            //                var price = $('#<= txtPrice.ClientID %>').val();
            //                var phantram = $('#<= txtDiscountPercent.ClientID %>').val();
            //                var value = (price / 100) * (100 - phantram);
            //                $('#<= txtPriceOff.ClientID %>').val(parseFloat(value));

            //            });
        });


    </script>
    <Telerik:RadTabStrip ID="McTabStrip1" runat="server" MultiPageID="RadMultiPage2"
        CausesValidation="False" SelectedIndex="0">
        <Tabs>
            <Telerik:RadTab Text="Thông tin sản phẩm" ImageUrl="/AdminCP/Layouts/Images/1_active.png">
            </Telerik:RadTab>
            <Telerik:RadTab Text="Nhập giá sản phẩm" ImageUrl="/AdminCP/Layouts/Images/2_disable.png">
            </Telerik:RadTab>
            <Telerik:RadTab Text="Thêm ảnh sản phẩm" ImageUrl="/AdminCP/Layouts/Images/2_disable.png"
                DisabledImageUrl="/AdminCP/Layouts/Images/2_disable.png" HoveredImageUrl="/AdminCP/Layouts/Images/2_active.png"
                SelectedImageUrl="/AdminCP/Layouts/Images/2_normal.png" Selected="True">
            </Telerik:RadTab>
        </Tabs>
    </Telerik:RadTabStrip>
    <Telerik:RadMultiPage ID="RadMultiPage2" runat="server" SelectedIndex="0" Width="100%">
        <Telerik:RadPageView ID="RadPageView1" runat="server" BorderColor="red">
            <script type="text/javascript">
                function OpenFileExplorerDialog() {
                    var wnd = $find("<%= ExplorerWindow.ClientID %>");

                    wnd.show();
                }


                //This function is called from a code declared on the Explorer.aspx page
                function OnFileSelected(fileSelected) {

                    var textbox = $find("<%= txtFileName.ClientID %>");
                    textbox.set_value(fileSelected);
                }



                function OpenFileExplorerDialog2() {
                    var wnd = $find("<%= ExplorerWindowImage.ClientID %>");

                    wnd.show();
                }

                function OnFileSelected2(fileSelected) {

                    var textbox = $find("<%= txtProductImage.ClientID %>");
                    textbox.set_value(fileSelected);
                }
            </script>
            <Telerik:RadWindow runat="server" Width="800px" Height="450px" VisibleStatusbar="false"
                ShowContentDuringLoad="false" NavigateUrl="/AdminCP/Pages/Explorer.aspx" ID="ExplorerWindow"
                Modal="true" Behaviors="Close,Move">
            </Telerik:RadWindow>
            <Telerik:RadWindow runat="server" Width="800px" Height="450px" VisibleStatusbar="false"
                ShowContentDuringLoad="false" NavigateUrl="/AdminCP/Pages/Explorer2.aspx" ID="ExplorerWindowImage"
                Modal="true" Behaviors="Close,Move">
            </Telerik:RadWindow>
            <asp:HiddenField ID="hfCategoryId" runat="server" />
            <table>
                <tr>
                    <td>
                        <div class="fleft" style="font-weight: bold; width: 120px; text-align: right; color: #00156E;
                            font-size: 12px;">
                            Chuyên mục:</div>
                    </td>
                    <td valign="top">
                        <Telerik:RadTreeView ID="radTreeCategories" runat="server" Width="300px" Height="200px">
                            <DataBindings>
                                <Telerik:RadTreeNodeBinding Expanded="True" />
                            </DataBindings>
                        </Telerik:RadTreeView>
                    </td>
                    <td>
                    </td>
                </tr>
            </table>
            <div class="item">
                <label>
                    Tên:</label><Telerik:RadTextBox runat="server" ID="txtName" Width="50%" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" Display="Dynamic" ForeColor="red"
                    ControlToValidate="txtName" runat="server" ErrorMessage="*" />
            </div>
            <div class="item">
                <label>
                    Tên không dấu:</label><Telerik:RadTextBox runat="server" ID="txtUnsignName" Width="50%" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" Display="Dynamic" ForeColor="red"
                    ControlToValidate="txtUnsignName" runat="server" ErrorMessage="*" />
            </div>
            <div class="item">
                <label>
                    Ảnh đại diện:</label><Telerik:RadTextBox runat="server" ID="txtFileName" Width="50%" /><span
                        style="display: inline-block; cursor: pointer; font-size: 12px;" id="btnUpload"
                        onclick="OpenFileExplorerDialog(); return false;"><strong>Chọn ảnh...</strong></span>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" Display="Dynamic" ForeColor="red"
                    ControlToValidate="txtFileName" runat="server" ErrorMessage="*" />
            </div>
            <%--<div class="item">
                <label>Giá:</label><Telerik:RadNumericTextBox runat="server" ID="txtPrice" Width="20%" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" Display="Dynamic" ForeColor="red" ControlToValidate="txtPrice" runat="server" ErrorMessage="*" />
            </div>
            <div class="item">
                <label>Phần trăm giảm giá:</label><Telerik:RadTextBox runat="server" ID="txtDiscountPercent" Width="15%" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator42" Display="Dynamic" ForeColor="red" ControlToValidate="txtDiscountPercent" runat="server" ErrorMessage="*" />
            </div>
            <div class="item">
                <label>Giá khuyến mại:</label><Telerik:RadTextBox runat="server" ID="txtPriceOff" Width="20%" />
            </div>--%>
            <div class="item">
                <label>
                    Đơn vị mặc định:</label><Telerik:RadComboBox runat="server" ID="UnitDefaultCbb"
                        Width="50%" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" Display="Dynamic" ForeColor="red"
                    ControlToValidate="UnitDefaultCbb" runat="server" ErrorMessage="*" />
            </div>
            <div class="item">
                <label>
                    Thông tin khuyến mại:</label><Telerik:RadTextBox runat="server" ID="txtDesDiscount"
                        TextMode="MultiLine" Width="70%" />
            </div>
            <div class="item">
                <label>
                    Mô tả:</label><Telerik:RadTextBox runat="server" ID="edtDescription" TextMode="MultiLine"
                        Width="70%" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" Display="Dynamic" ForeColor="red"
                    ControlToValidate="edtDescription" runat="server" ErrorMessage="*" />
            </div>
            <div class="item">
                <table>
                    <tr>
                        <td>
                            <div class="fleft" style="font-weight: bold; width: 120px; text-align: right; color: #00156E;
                                font-size: 12px;">
                                Chi tiết:</div>
                        </td>
                        <td>
                            <Telerik:RadEditor runat="server" ID="edtDetail" Width="80%">
                                <ImageManager UploadPaths="~/Upload" DeletePaths="~/Upload" ViewPaths="~/Upload"
                                    ImageEditorFileSuffix="~/Upload/"></ImageManager>
                            </Telerik:RadEditor>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="item">
                <label>
                    Chức năng:</label>
                <asp:CheckBox runat="server" Text="Khuyến mãi" CssClass="option" ID="IsSalesOff"
                    AutoPostBack="False" />
                <asp:CheckBox runat="server" Text="Nhóm mua" CssClass="option" ID="cbIsGroupBuy"
                    AutoPostBack="False" />
            </div>
            <div class="item">
                <label>
                    Ngày tạo:</label><Telerik:RadDateTimePicker runat="server" ID="radCreateDate" Width="218px" />
            </div>
            <div class="item" style="padding-bottom: 30px">
                <label>
                </label>
                <Telerik:RadButton runat="server" ID="btnSave" OnClick="btnSave_OnClick">
                </Telerik:RadButton>
                <Telerik:RadButton ID="btnReset" runat="server" Text="Làm lại" OnClick="OnClick"
                    CausesValidation="False">
                </Telerik:RadButton>
            </div>
        </Telerik:RadPageView>
        <Telerik:RadPageView ID="RadPageView2" runat="server" BorderColor="red">
            <asp:Panel runat="server" ID="pnlAddPriceProductImage">
                <div class="item">
                    <label>
                        Đơn vị thuốc:</label><Telerik:RadComboBox runat="server" ID="UnitCbb" Width="50%" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator7" Display="Dynamic" ForeColor="red"
                        ControlToValidate="UnitCbb" runat="server" ErrorMessage="*" />
                </div>
                <div class="item">
                    <label>
                        Giá:</label><Telerik:RadTextBox runat="server" ID="txtPriceUnit" Width="350px" />
                    <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator66" Display="Dynamic" ForeColor="red"
                        ControlToValidate="txtPriceUnit" runat="server" ErrorMessage="*" />--%>
                </div>
                <div class="item">
                    <label>
                        Giảm giá:</label><Telerik:RadTextBox runat="server" ID="txtPriceUnitDiscountPercent"
                            Width="350px" />%
                   <%-- <asp:RequiredFieldValidator ID="RequiredFieldValidator76" Display="Dynamic" ForeColor="red"
                        ControlToValidate="txtPriceUnitDiscountPercent" runat="server" ErrorMessage="*" />--%>
                </div>
                <div class="item" style="padding-bottom: 30px">
                    <label>
                    </label>
                    <Telerik:RadButton runat="server" ID="btnPriceSave" Text="Thêm" OnClick="btnPriceSave_OnClick">
                    </Telerik:RadButton>
                    <Telerik:RadButton ID="RadButton22" runat="server" Text="Làm lại" OnClick="OnClick"
                        CausesValidation="False">
                    </Telerik:RadButton>
                </div>
                <Telerik:RadGrid runat="server" ID="gridDataPrice" CellSpacing="0" GridLines="None"
                    Width="100%" AutoGenerateColumns="False" AllowPaging="True" AllowCustomPaging="True"
                  AllowSorting="True" OnItemCommand="gridDataPrice_ItemCommand">
                    <MasterTableView ClientDataKeyNames="Id" DataKeyNames="Id" GroupLoadMode="Client"
                        PageSize="20" NoMasterRecordsText="Không có bản ghi nào.">
                        <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                        <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </ExpandCollapseColumn>
                        <GroupByExpressions>
                        </GroupByExpressions>
                        <Columns>
                        <Telerik:GridBoundColumn runat="server" UniqueName="Id" DataField="Id" Visible="false"/>
                            <Telerik:GridTemplateColumn HeaderText="STT" UniqueName="STT">
                                <ItemStyle HorizontalAlign="Left" CssClass="center" />
                                <ItemTemplate>
                                    <%#
                   (gridData.PageSize * (gridData.CurrentPageIndex + 1)) - gridData.PageSize + Container.ItemIndex + 1
                                    %>
                                </ItemTemplate>
                                <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="50px" />
                            </Telerik:GridTemplateColumn>
                            <Telerik:GridTemplateColumn HeaderText="Đơn vị thuốc" UniqueName="Unit">
                                <ItemStyle HorizontalAlign="Left" CssClass="center" />
                                <ItemTemplate>
                                    <%#  Enum.GetName(typeof(Thuoc24h.Common.Enums.Unit),Eval("Unit"))%>
                                </ItemTemplate>
                                <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="50px" />
                            </Telerik:GridTemplateColumn>
                            <Telerik:GridTemplateColumn HeaderText="Giá" UniqueName="Price">
                                <ItemStyle HorizontalAlign="Left" CssClass="center" />
                                <ItemTemplate>
                                    <%# Eval("Price")%>
                                </ItemTemplate>
                                <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="50px" />
                            </Telerik:GridTemplateColumn>
                            <Telerik:GridTemplateColumn HeaderText="Giảm giá" UniqueName="DiscountPercent">
                                <ItemStyle HorizontalAlign="Left" CssClass="center" />
                                <ItemTemplate>
                                    <%# Eval("DiscountPercent")%>
                                </ItemTemplate>
                                <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="50px" />
                            </Telerik:GridTemplateColumn>
                            <Telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmDialogType="RadWindow"
                                ConfirmText="Bạn có chắc chắn muốn xóa" ConfirmTitle="Xóa" HeaderText="X&#243;a"
                                Text="X&#243;a" UniqueName="Delete">
                                <ItemStyle CssClass="center" Width="32px" />
                                <HeaderStyle HorizontalAlign="Center" Width="32px" Font-Bold="True" />
                            </Telerik:GridButtonColumn>
                        </Columns>
                        <EditFormSettings EditFormType="Template">
                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                            </EditColumn>
                        </EditFormSettings>
                    </MasterTableView>
                    <ClientSettings EnableRowHoverStyle="True">
                    </ClientSettings>
                    <FilterMenu EnableImageSprites="False">
                    </FilterMenu>
                    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                    </HeaderContextMenu>
                </Telerik:RadGrid>
            </asp:Panel>
            <asp:Label runat="server" ID="lnPriceNoti"></asp:Label>
        </Telerik:RadPageView>
        <Telerik:RadPageView ID="RadPageView3" runat="server" BorderColor="red">
            <asp:Panel runat="server" ID="pnlAddProductImage">
                <div class="item">
                    <label>
                        Ảnh:</label><Telerik:RadTextBox runat="server" ID="txtProductImage" Width="350px" /><span
                            style="display: inline-block; cursor: pointer; font-size: 12px;" id="Span1" onclick="OpenFileExplorerDialog2(); return false;"><strong>Chọn
                                ảnh...</strong></span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator6" Display="Dynamic" ForeColor="red"
                        ControlToValidate="txtUnsignName" runat="server" ErrorMessage="*" />
                </div>
                <div class="item" style="padding-bottom: 30px">
                    <label>
                    </label>
                    <Telerik:RadButton runat="server" ID="btnImageSave" Text="Thêm" OnClick="btnImageSave_OnClick">
                    </Telerik:RadButton>
                    <Telerik:RadButton ID="RadButton2" runat="server" Text="Làm lại" OnClick="OnClick"
                        CausesValidation="False">
                    </Telerik:RadButton>
                    <Telerik:RadButton ID="btFinish" runat="server" Text="Hoàn tất" OnClick="btFinish_OnClick"
                        CausesValidation="False">
                    </Telerik:RadButton>
                </div>
                <Telerik:RadGrid runat="server" ID="gridData" CellSpacing="0" GridLines="None" Width="100%"
                    AutoGenerateColumns="False" AllowPaging="True" AllowCustomPaging="True" OnItemCommand="gridData_ItemCommand"
                    AllowSorting="True">
                    <MasterTableView ClientDataKeyNames="Id" DataKeyNames="Id" GroupLoadMode="Client"
                        PageSize="20" NoMasterRecordsText="Không có bản ghi nào.">
                        <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                        <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </ExpandCollapseColumn>
                        <GroupByExpressions>
                        </GroupByExpressions>
                        <Columns>
                            <Telerik:GridTemplateColumn HeaderText="STT" UniqueName="Id">
                                <ItemStyle HorizontalAlign="Left" CssClass="center" />
                                <ItemTemplate>
                                    <%#
                   (gridData.PageSize * (gridData.CurrentPageIndex + 1)) - gridData.PageSize + Container.ItemIndex + 1
                                    %>
                                </ItemTemplate>
                                <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="50px" />
                            </Telerik:GridTemplateColumn>
                            <Telerik:GridImageColumn FilterControlAltText="Filter column column" ImageHeight=""
                                ImageWidth="80" DataImageUrlFields="ImageUrl" UniqueName="column">
                            </Telerik:GridImageColumn>
                            <Telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmDialogType="RadWindow"
                                ConfirmText="Bạn có chắc chắn muốn xóa" ConfirmTitle="Xóa" HeaderText="X&#243;a"
                                Text="X&#243;a" UniqueName="Delete">
                                <ItemStyle CssClass="center" Width="32px" />
                                <HeaderStyle HorizontalAlign="Center" Width="32px" Font-Bold="True" />
                            </Telerik:GridButtonColumn>
                        </Columns>
                        <EditFormSettings EditFormType="Template">
                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                            </EditColumn>
                        </EditFormSettings>
                    </MasterTableView>
                    <ClientSettings EnableRowHoverStyle="True">
                    </ClientSettings>
                    <FilterMenu EnableImageSprites="False">
                    </FilterMenu>
                    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                    </HeaderContextMenu>
                </Telerik:RadGrid>
            </asp:Panel>
            <asp:Label runat="server" ID="lnNoti"></asp:Label>
        </Telerik:RadPageView>
    </Telerik:RadMultiPage>
</asp:Content>
